package com.lj.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lj.mapper.DepartmentljMapper;
import com.lj.mapper.DirectorljMapper;
import com.lj.pojo.Departmentlj;
import com.lj.pojo.DepartmentljExample;
import com.lj.pojo.Directorlj;
import com.lj.pojo.DirectorljExample;
import com.lj.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {
    @Autowired
    DepartmentljMapper departmentljMapper;
    @Override
    public PageInfo selectDepartment(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        DepartmentljExample example=new DepartmentljExample();
        example.setOrderByClause("department_name desc");
        List<Departmentlj> list=departmentljMapper.selectByExample(example);
        PageInfo<Departmentlj> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int insertDepartment(Departmentlj departmentlj) {
        return departmentljMapper.insert(departmentlj);
    }

    @Override
    public int delete(String id) {
        return departmentljMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Departmentlj getById(String id) {
        return departmentljMapper.selectByPrimaryKey(id);
    }

    @Override
    public int update(Departmentlj departmentlj) {
        return departmentljMapper.updateByPrimaryKey(departmentlj);
    }
}
